#include <bits/stdc++.h>
using namespace std;
int main()
{
  unordered_map<char,int> hash;
  string s;
  cin>>s;
  int n=s.size();
  int maxcount=0;
  char maxval;
  int mincount=INT_MAX;
  char minval;
  bool check=false;
  for(int i=0;i<n;++i)
  {
    ++hash[s[i]];
  }
  for(auto& ch:s)
  {
  	if(maxcount<hash[ch])
    {
      maxcount=hash[ch];
      maxval=ch;
    }
    if(mincount>hash[ch])
    {
      mincount=hash[ch];
      minval=ch;
    }
	} 
	if(maxval!=minval)
	{
		int x=maxcount-mincount;
    cout<<x;
	}
	else
	{
		cout<<n;
	}
    
  
  return 0;
}
